<?php
/**
 * Created by PhpStorm.
 * User: yyq
 * Date: 2017/12/23
 * Time: 19:19
 */

namespace Common\Model;


class CategoryModel extends CommonModel
{
    /**
     * @param $id
     * @return string
     */
    public function getOption($id = 0) {
        $result = $this->select();
        $option = '';
        foreach ($result as $k => $v) {
            if($id == $v['id']) {
                $option .= '<option selected value="'.$v['id'].'">'.$v['name'].'</option>';
            } else {
                $option .= '<option value="'.$v['id'].'">'.$v['name'].'</option>';
            }
        }
        return $option;
    }
}